import { ScaleEditing } from "@czmSrc/EditingSystem/base";
import { ESCesiumViewer } from "@czmSrc/ESCesiumViewer";
import { ESJEditingMode, ESSceneObject } from "earthsdk3";
import { bind, nextAnimateFrame } from "xbsj-base";
import { BaseEditingWrapper } from "./BaseEditingWrapper";
export class ScaleEditingWrapper extends BaseEditingWrapper {
    static readonly type = this.registerEditing("ESCesiumViewer", ESJEditingMode.Scale, this);
    constructor(sceneObject: ESSceneObject, czmViewer: ESCesiumViewer) {
        super(sceneObject, czmViewer, true);
        const scaleEditing = this.currentEditing = this.ad(new ScaleEditing(czmViewer));
        this.ad(scaleEditing.enabledChanged.don((newVal) => {
            !newVal && this.ad(nextAnimateFrame(() => {
                this.destroy();
            }));
        }));
        do {
            if (Reflect.has(sceneObject, 'position') && Reflect.has(sceneObject, 'scale')) {
                //@ts-ignore
                this.ad(bind([scaleEditing, 'position'], [sceneObject, 'position']));
                //@ts-ignore
                this.ad(bind([scaleEditing, 'scale'], [sceneObject, 'scale']));
                break;
            }
            this.supportEditing = false;
        } while (false);
    }
}